/*
*************************************************
				Copyagent
	------------------------------------------
	            bd_test.c
*************************************************
Testeaza interactiunea cu baza de date
*/
#include <string.h>
#include <stdio.h>
#include <mysql/mysql.h>

MYSQL mysql;
MYSQL_RES *res;
MYSQL_ROW row; 


int test()
{
	int ret = 0;
	char query[80]; 

	mysql_init(&mysql);

	printf("MySQL Client Version is %s\n",mysql_get_client_info());
	/* now call other API's*/

if (!mysql_real_connect(&mysql,"10.0.0.1","copyagent","pentium2",NULL/*variation #2*/,0,NULL,0)) 
{
    printf( "Failed to connect to MySQL: Error: %s\n", mysql_error(&mysql));
    exit(1);
}
//mysql_select_db(&mysql, "copyagent")
		
sprintf(query,"INSERT into copyagent.aparitii (propozitie, domeniu, url_complet) VALUES ('%s','%s','%s');", "A", "B", "C"); 
   
 //sprintf(query,"SELECT * FROM mysql.user"); 
 ret = mysql_real_query(&mysql,query,(unsigned int)strlen(query));
 printf("%s \n",mysql_error(&mysql));
 fflush(stdout);
//   res = mysql_use_result(&mysql);
//   while(row = mysql_fetch_row(res))
 //   printf("%s %s\n",row[0],row[1]);
 //  mysql_free_result(res); 
	mysql_close(&mysql);
	return 0;
}

int main (int argc, char *argv[])
{
	test();
	return 0;
}



